package xyz.chaobei;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import xyz.chaobei.entity.User;
import xyz.chaobei.mapper.UserMapper;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;

/**
 * Copyright (C), 2015-2019
 * FileName: Test
 * Author:   MRC
 * Date:     2019/10/25 15:16
 * Description:
 * History:
 */
public class Test {


    public static void main(String[] args) throws IOException {

        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

        SqlSession sqlSession = sqlSessionFactory.openSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);

        List<User> list = userMapper.selectAll();

        System.out.println(list.getClass().toString());
        System.out.println(list.toString());

        int num = userMapper.update();
        System.out.println("修改数量=" + num);

        sqlSession.close();
    }
}